package cn.bdqn.appinfo.controller;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.bdqn.appinfo.entity.User;
import cn.bdqn.appinfo.util.Result;

@Controller
@RequestMapping("/admin")
public class UserController {
	
	@RequestMapping(value="/login",method={RequestMethod.POST})
	@ResponseBody
	public Result login(String username, String password, HttpSession session) {
		if("admin".equals(username)) {
			User user = new User();
			user.setId(1);
			user.setUsername(username);
			user.setPassword(password);
			session.setAttribute("loginUser", user);
			System.out.println("login:" + session.getId());
			return Result.ok(user);
		} else {
			return Result.error("用户名或密码错误");
		}
	}
}
